<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div class="box">
        <span>数据A：</span><input placeholder='12' type="text" v-model='a'><br>
        <span>数据B：</span><input type="text" v-model='b' @keyup.enter='sum'><br>
        <button v-on:click='sum'>计算</button>
        <div>计算结果：{{result}}</div>
    </div>
    <script>
        let vm = new Vue({
            el: '.box',
            data: {
                a: '',
                b: '',
                result: '',
            },
            methods: {
                sum() {
                    // this.result = +this.a + +this.b
                    this.result = parseInt(this.a) + parseInt(this.b)
                }
            }
        })
    </script>
</body>

</html>